package coml.jiyun.hp.day09;


import android.content.Context;
import android.util.AttributeSet;
import android.util.Log;
import android.view.MotionEvent;
import android.view.View;

import androidx.annotation.Nullable;

public class MyView extends View {

    String TAG  = "MyView";

    public MyView(Context context, @Nullable AttributeSet attrs) {
        super(context, attrs);
    }

    //处理事件的方法

    @Override
    public boolean dispatchTouchEvent(MotionEvent event) {
        Log.d(TAG, "dispatchTouchEvent: "+event.getAction());
        //super.dispatchTouchEvent(event) 事件分发
        //true:事件消费
        //fasle:事件给到父容器 的onTouchEvent()
        return super.dispatchTouchEvent(event);
    }
    //处理事件的方法

    @Override
    public boolean onTouchEvent(MotionEvent event) {
        Log.d(TAG, "onTouchEvent: "+event.getAction());
        //返回值为 ture时   消费
        //返回值为false时 和 super一样，事件给到父容器的onTouchEvent
        return true;
    }
}
